gt styling

This document shows some of the ways that you can format and style tables created using the gt R package.

gt tables have a clearly articulated structure as shown in the syntax used in Figure 1.

Figure 1: Source: gt.rstudio.com

A gt table can be styled by targeting parts such as the Spanner or Stubhead by using the corresponding helper() functions. We will generally apply formatting and styles to these table locations using the tab_style() or tab_options() functions.

Typeface

tbl |> 
  tab_style(
      style = cell_text(
        font = list(
          google_font(name = "Walter Turncoat"))
        ),
      locations = cells_title(groups = "title")
      )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(
      font = google_font("Playfair"), 
      weight = "bold",
      size = px(20)
      ),
    locations = cells_column_labels(everything())
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(
      font = google_font("Roboto Mono")),
    locations = cells_body(columns = everything())
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  opt_table_font(font = google_font("Source Sans Pro"))
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%

Font

tbl |> 
  tab_style(
    style = cell_text(weight = "bold"),
    locations = cells_stubhead()
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_options(row_group.font.weight = "bold")
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(style = "italic"),
    locations = cells_column_labels(columns = everything())
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(color =   "#756bb1", weight = "bold"),
    locations = cells_column_spanners()
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_options(column_labels.font.weight = "bold")
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(weight = "bold"),
    locations = cells_body(columns = "change")
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(weight = "bold"),
    locations = list(cells_stub_summary(),
                     cells_summary())
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |>  
  tab_style(
    style = cell_text(weight = "bold"),
    locations = list(cells_stub_grand_summary(),
                     cells_grand_summary())
    )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%

Alignment

tbl |> 
  tab_style(
    style = cell_text(align = "center", v_align = "middle"),
    locations = cells_stubhead()
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(align = "center"),
    locations = cells_column_labels(columns = everything())
    )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%

Width

tbl |> 
  cols_width(
    country_name ~ px(180),
    everything() ~ px(60)
)
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_options(
    table.width = pct(50)
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%

Borders

tbl |> 
  opt_table_lines("none") |> 
  tab_options(
    stub.border.style = "solid",
    stub.border.width = px(2),
    stub.border.color = "#000000"
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
   opt_table_lines("none") |> 
  tab_style(
    style = cell_borders(sides = "bottom", color = "#000000", weight = px(2)),
    locations = cells_row_groups()
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  opt_table_lines("none") |> 
  tab_style(
  style = cell_borders(sides = "left", color = "#000000", weight = px(2)),
  locations = cells_column_labels(columns = everything())
  ) |> 
  tab_style(
    style = cell_borders(sides = "right", style = "hidden"),
    locations = cells_column_spanners("Year")
    ) 
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  opt_table_lines("none") |> 
  tab_style(
  style = cell_borders(sides = "left", color = "#000000", weight = px(2)),
  locations = list(
    cells_body(columns = `2022`),
    cells_summary(columns = `2022`))
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  opt_table_lines("none") |> 
  tab_style(
    style = cell_borders(sides = "bottom", color = "#000000", weight = px(2)),
    locations = cells_body(rows = country_name == "United Arab Emirates")
    )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  opt_table_lines("none") |> 
  tab_options(
    heading.border.lr.style = "hidden",
    heading.border.bottom.style = "solid",
    heading.border.bottom.width = px(2),
    heading.border.bottom.color = "#000000",
    table.border.left.style = "solid",
    table.border.left.width = px(2),
    table.border.left.color = "#000000",
    table.border.right.style = "solid",
    table.border.right.width = px(2),
    table.border.right.color = "#000000",
    table.border.bottom.color = "#000000",
    table.border.bottom.style = "solid",
    table.border.bottom.width = px(2),
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%

Highlighting

tbl |> 
  tab_style(
        style = cell_text(color = "red", weight = "bold"),
        locations = cells_body(columns = change, 
                               rows = change == min(change))
        )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%
tbl |> 
  tab_style(
    style = cell_text(color = "seagreen", weight = "bold"),
    locations = list(cells_stub(rows = change >= 0.4),
                     cells_body(rows = change >= 0.4))
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%

Download button

library(downloadthis)
tbl |> 
  tab_source_note(
    df |> 
      download_this(
        output_name = "tbl-17",
        output_extension = ".csv",
        csv2 = FALSE,
        button_label = "Download CSV",
        button_type = "default"
      )
  )
Population of countries belonging to the League of Arab States
Government type Year Change
2012 2022
Monarchy
Jordan 7.21M 11.29M 56.5%
Qatar 1.91M 2.70M 41.4%
Oman 3.54M 4.58M 29.4%
Kuwait 3.39M 4.27M 25.8%
Bahrain 1.22M 1.47M 20.2%
Saudi Arabia 30.82M 36.41M 18.1%
Morocco 33.35M 37.46M 12.3%
United Arab Emirates 8.66M 9.44M 9.0%
Total 90.1M 107.6M 19.4%
Republic
Somalia 12.44M 17.60M 41.5%
Sudan 35.16M 46.87M 33.3%
Iraq 33.86M 44.50M 31.4%
Mauritania 3.64M 4.74M 30.3%
Yemen 26.22M 33.70M 28.5%
West Bank and Gaza 3.98M 5.04M 26.7%
Comoros 684.55K 836.77K 22.2%
Egypt 91.24M 110.99M 21.6%
Algeria 37.26M 44.90M 20.5%
Djibouti 954.30K 1.12M 17.5%
Libya 5.87M 6.81M 16.1%
Tunisia 11.17M 12.36M 10.6%
Lebanon 5.18M 5.49M 6.0%
Syrian Arab Republic 22.61M 22.13M −2.1%
Total 290.3M 357.1M 23.0%
Grand Total 380.38M 464.68M 22.2%